package pers.lx.crm.controller.info;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.lx.crm.base.common.pigeon.Result;
import pers.lx.crm.entiy.info.CustomerDO;
import pers.lx.crm.entiy.info.InfoListDO;
import pers.lx.crm.service.info.CustomerService;

/**
 * Created by lx on 2017/3/7.
 */
@Controller
@RequestMapping(value = "customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService ;

    @RequestMapping(value = "/list")
    public @ResponseBody
    Result getCustomers(CustomerDO customerDo){
        return customerService.getCustomers(customerDo) ;
    }

    @RequestMapping(value = "/get")
    public @ResponseBody
    Result getCustomer(@RequestBody CustomerDO customerDO){
        return customerService.getCustomer(customerDO) ;
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public @ResponseBody
    Result addCustomer(@RequestBody CustomerDO customerDO){
        return customerService.addCustomer(customerDO) ;
    }

    @RequestMapping(value = "/update")
    public @ResponseBody
    Result updateCustomer(@RequestBody CustomerDO customerDO){
        return customerService.updateCustomer(customerDO) ;
    }

    @RequestMapping(value = "/remove")
    public @ResponseBody
    Result removeCustomer(@RequestBody InfoListDO infoListDO){
        return customerService.deleteCustomer(infoListDO.getCustomerDOs()) ;
    }
}
